import requests
import time, hmac, hashlib, base64

# 配置参数
# webhook_url = "http://8.130.183.111:8899/dingtalk/webhook"  # 你的接口地址
# webhook_url = "http://127.0.0.1:8890/dingtalk/webhook"  # 你的接口地址
webhook_url = "http://47.110.77.58:8899/dingtalk/webhook"  # 你的接口地址
secret = "test123"  # 你提供的加签密钥
# content = "https://meters.officemate.cn/track/share-plan-report?shareId=31df40a2-f1a4-4b72-b82e-4b10ae3b0ed9"  # 要发送的内容
# content = "https://meters.officemate.cn/track/share-plan-report?shareId=d4c7e56f-6966-44b4-935e-bcc7285ace4d"# 要发送的内容
content = "https://meters.officemate.cn/track/share-plan-report?shareId=1a843145-c51f-4d4d-8c25-cce2faf8828a"

# # 1. 生成签名
# timestamp = str(int(time.time() * 1000))
# string_to_sign = f"{timestamp}\n{secret}"
# sign = base64.b64encode(
#     hmac.new(secret.encode(), string_to_sign.encode(), digestmod=hashlib.sha256).digest()
# ).decode()

# 2. 构造请求头
headers = {
    "Content-Type": "application/json",

}

# 3. 构造请求体
payload = {
    "msgtype": "text",
    "text": {"content": content}
}

# 4. 发送请求
response = requests.post(webhook_url, json=payload, headers=headers)
print("响应状态码:", response.status_code)
# print("响应内容:", response.json())
